package com.example.example02;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class SpeakerDriver {
  public void Start(String inputPaths,String outputPath) throws IOException, ClassNotFoundException, InterruptedException{
    Configuration config = new Configuration();
    Job job = Job.getInstance(config);
    job.setJarByClass(SpeakerDriver.class);
    job.setMapperClass(SpeakDurationMapper.class);
    job.setReducerClass(SpeakDurationReducer.class);
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(SpeakBean.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(SpeakBean.class);
    FileInputFormat.setInputPaths(job, new Path(inputPaths));
    FileOutputFormat.setOutputPath(job, new Path(outputPath));
    boolean result = job.waitForCompletion(true);
    System.exit(result ? 0 : 1);
  }
}
